package com.wondersgroup.insurance.dnuilearn.viewgroups.tables;

import android.view.View;

import java.util.Stack;

/**
 * <b>Project:</b> dnuilearn<br>
 * <b>Create Date:</b> 2017/6/8 0008<br>
 * <b>Author:</b> huang saisai <br>
 * <b>Description:</b> <br>
 */
public class Recycler {
    private Stack<View> [] views;
    int typeCount=1;
    //打造一个回收池


    public Recycler(int typeCount) {

        if (typeCount <1){
            typeCount = 1;
        }
        this.typeCount = typeCount;
        views=new Stack[typeCount];
        for (int i=0;i<typeCount;i++) {
            views[i]=new Stack<View>();
        }
    }

    public void addRecycledView(View view, int type){
        if (type > 0 && type <typeCount&& view !=null){
            views[type].push(view);
        }

    }

    public View getRecyclerdView(int type) {
        if (type > 0 && type <typeCount && views[type].size()>0 ){
            return views[type].pop();
        }
            return null;
    }
}
